<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Template.Master" Inherits="IWS.SiteManager.Web.Views.LayoutView<IWS.SiteManager.Core.Model.SetupInformation>" %>

<asp:Content ID="Content2" ContentPlaceHolderID="HeadContent" runat="server">
	<style type="text/css">
	</style>
	<script type="text/javascript">
		$().ready(function() {
			if (!$("#MDBDifferent").attr("checked")) {
				$("#divMembershipNotShared").hide();
			}

			$("#MDBDifferent").change(function() {
				if ($(this).attr("checked"))
					$("#divMembershipNotShared").slideDown();
				else
					$("#divMembershipNotShared").slideUp();
			});

			$("#frmMain").submit(function() {

				//validate required

				//validate password confirm
			if ($("#AdminPass").val() != $("#AdminPassConfirm").val()) {
					alert("password confirm mismatch");
					return false;
				}

				return true;
			});
		});
	</script>
</asp:Content>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
	<h2>New Installation</h2>
	<p>This installation process will setup and configure a brand new database with default settings.</p>
	<h3>SiteManager Database</h3>
<%	using (Html.BeginForm("Index", "Install", FormMethod.Post, new { id="frmMain", name="frmMain"}))
	{ %>
<%=Html.ValidationSummary()%>
<div class="MessageBox">
<%=ViewData["Exception"] != null ? HttpUtility.HtmlEncode(((Exception)ViewData["Exception"]).Message).Replace("\n","<br/>") : string.Empty%>

<%if (ViewData["Exception"] is System.Security.SecurityException)
  { %>
<p>If you're in a medium trust environment, try to <%=Html.ActionLink("click here to continue to step 2", "Step2", "Install")%>. </p>
<%} %>
</div>
<%		var types = new List<SelectListItem>();
		types.Add(new SelectListItem { Text = "Microsoft Sql Server", Value = "1", Selected = true });
		//types.Add(new SelectListItem { Text="MySql Server", Value="2"});
		//types.Add(new SelectListItem { Text="SqlLite", Value="3"});
%>
	<table class="form">
		<tr>
			<th><label for="DBType">Type:</label></th>
			<td><%=Html.DropDownList("DBType", types)%>
				<%=Html.ValidationMessage("DBType", "*")%></td>
		</tr>
		<tr>
			<th><label for="DBHost">Hostname:</label></th>
			<td><%=Html.TextBox("DBHost", Model.DBHost)%>
				<%=Html.ValidationMessage("DBHost", "*")%></td>
		</tr>
		<tr>
			<th><label for="DBName">Database:</label></th>
			<td><%=Html.TextBox("DBName", Model.DBName)%>
			<%=Html.ValidationMessage("DBName", "*")%></td>
		</tr>
		<tr>
			<th><label for="DBUser">Username:</label></th>
			<td><%=Html.TextBox("DBUser", Model.DBUser)%>
			<%=Html.ValidationMessage("DBUser", "*")%></td>
		</tr>
		<tr>
			<th><label for="DBPass">Password:</label></th>
			<td><%=Html.Password("DBPass", Model.DBPass)%>
			<%=Html.ValidationMessage("DBPass", "*")%></td>
		</tr>
		<tr>
			<th>&nbsp;</th>
			<td><%=string.Format("<input type=\"checkbox\" id=\"{0}\" name=\"{0}\" value=\"true\" {1} />","DBIntegrated", Model.DBIntegrated ? "checked" : string.Empty)%> <label for="DBIntegrated">Use Integrated Security</label></td>
		</tr>
	</table>
	
	<h3>Membership Database</h3>
	<p><%=string.Format("<input type=\"checkbox\" id=\"{0}\" name=\"{0}\" value=\"true\" {1} />","MDBDifferent", Model.MDBDifferent ? "checked" : string.Empty)%> <label for="MDBDifferent">Check here if you want to install Membership schema to a DIFFERENT database. </label></p>
	<div id="divMembershipNotShared">
		<table class="form">
			<tr>
				<th><label for="MDBHost">Hostname:</label></th>
				<td><%=Html.TextBox("MDBHost", "localhost")%>
				<%=Html.ValidationMessage("MDBHost", "*")%></td>
			</tr>
			<tr>
				<th><label for="MDBName">Database:</label></th>
				<td><%=Html.TextBox("MDBName", "Membership")%>
				<%=Html.ValidationMessage("MDBName", "*")%></td>
			</tr>
			<tr>
				<th><label for="MDBUser">Username:</label></th>
				<td><%=Html.TextBox("MDBUser", string.Empty)%>
				<%=Html.ValidationMessage("MDBUser", "*")%></td>
			</tr>
			<tr>
				<th><label for="MDBPass">Password:</label></th>
				<td><%=Html.Password("MDBPass", string.Empty)%>
				<%=Html.ValidationMessage("MDBPass", "*")%></td>
			</tr>
			<tr>
				<th>&nbsp;</th>
				<td><%=string.Format("<input type=\"checkbox\" id=\"{0}\" name=\"{0}\" value=\"true\" {1} />", "MDBIntegrated", Model.MDBIntegrated ? "checked" : string.Empty)%> <label for="MDBIntegrated">Use Integrated Security</label></td>
			</tr>
		</table>
	</div>
	
	<p><input type="submit" value="Install Database" /></p>
<%	} %>	
</asp:Content>

